package com.xm.service;

import com.xm.dao.userDao;
import com.xm.pojo.User;
import com.xm.pojo.account;
import com.xm.pojo.product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class userServiceImpl implements userService{

    @Autowired
    private userDao userDao;


    /*根据用户名查询用户信息(登录)*/
    @Override
    public User login(String userName) {
        return userDao.login(userName);
    }

    @Override
    public User userInfoId(int id) {
        return userDao.userInfoId(id);
    }

    /*注册*/
    @Override
    public boolean zhuce(String userName, String pwd,String nickName) {
        return userDao.zhuce(userName,pwd,nickName);
    }

    /*注册成功后添加钱包*/
    @Override
    public boolean insertAccount(String userName,double amount,String charge) {
        return userDao.insertAccount(userName,amount,charge);
    }

    /*用户收藏（所有）*/
    @Override
    public List<product> wishlist(int userId) {
        return userDao.wishlist(userId);
    }

    /*用户收藏（单个） 商品详情页*/
    @Override
    public product wishlistInfo(int userId, int id) {
        return userDao.wishlistInfo(userId,id);
    }

    /*删除收藏（单/多个）*/
    @Override
    public boolean delWishInfo(int productId, int userId) {
        return userDao.delWishInfo(productId,userId);
    }

    /*删除收藏（全部）*/
    @Override
    public boolean delWish(int userId) {
        return userDao.delWish(userId);
    }

    /*新增收藏*/
    @Override
    public boolean addWish(int productId, int userId) {
        return userDao.addWish(productId,userId);
    }

    /*购物车*/
    @Override
    public List<product> carInfo(int userId) {
        return userDao.carInfo(userId);
    }

    /*新增购物车*/
    @Override
    public boolean addCar(int productId, int userId, int quantity, int skuId) {
        return userDao.addCar(productId,userId,quantity,skuId);
    }

    /*查询购物车是否存在商品*/
    @Override
    public product isCar(int userId, int productId, int skuId) {
        return userDao.isCar(userId,productId,skuId);
    }

    /*修改购物车数量*/
    @Override
    public boolean updateCar(int quantity, int userId, int productId, int skuId) {
        return userDao.updateCar(quantity,userId,productId,skuId);
    }

    /*
    * 删除购物车（单/多个）
    * */
    @Override
    public boolean delCarInfo(int productId, int userId, int skuId) {
        return userDao.delCarInfo(productId,userId,skuId);
    }

    @Override
    public boolean deleteCar(int id) {
        return userDao.deleteCar(id);
    }

    /*删除购物车（全部）*/
    @Override
    public boolean delUserCarInfo(int userId) {
        return userDao.delUserCarInfo(userId);
    }

    @Override
    public double remainder(String userName) {
        return userDao.remainder(userName);
    }

    @Override
    public double recharge(String userName) {
        return userDao.recharge(userName);
    }

    @Override
    public double consume(String userName) {
        return userDao.consume(userName);
    }

    @Override
    public boolean updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public boolean updateUserName(String userName, int id) {
        return userDao.updateUserName(userName,id);
    }

    @Override
    public boolean updateAccountUserName(String userName, String yuanuserName) {
        return userDao.updateAccountUserName(userName,yuanuserName);
    }


}
